//
//  UIBarButtonItem+Addition.m
//  THCustomer
//
//  Created by lichentao on 13-8-13.
//  Copyright (c) 2013年 efuture. All rights reserved.
//

#import "UIBarButtonItem+Addition.h"
#import "UIButton+Addition.h"

@implementation UIBarButtonItem (Addition)

// 返回 —— title 默认
+ (UIBarButtonItem *)backBarButtonItemWithTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
	return [UIBarButtonItem backBarButtonItemWithImage:@"back" target:target action:action forControlEvents:controlEvents];
}

// 返回 -- title
+ (UIBarButtonItem *)backBarButtonItemWithTitle:(NSString *)title target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
	UIButton        *backButton = [UIButton backButtonWithTitle:title target:target action:action forControlEvents:controlEvents ];
	UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc]  initWithCustomView:backButton];
	return backBarButtonItem;
}

// 返回 -- image
+ (UIBarButtonItem *)backBarButtonItemWithImage:(NSString *)image target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    UIButton        *rightButton  = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(10,6,46/2,46/2);
    [rightButton setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [rightButton addTarget:target action:action forControlEvents:controlEvents];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]  initWithCustomView:rightButton];
    return rightBarButtonItem;
}

// right - title
+ (UIBarButtonItem *)rightBarButtonItemWithTitle:(NSString *)title target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
	UIButton        *rightButton        =[UIButton rightButtonWithTitle:title target:target action:action forControlEvents:controlEvents ];
	UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]  initWithCustomView:rightButton];
	return rightBarButtonItem;
}

// right - image
+ (UIBarButtonItem *)rightBarButtonItemWithImage:(NSString *)image target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    UIButton        *rightButton  = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(10,6,46/2,46/2);
    [rightButton setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [rightButton addTarget:target action:action forControlEvents:controlEvents];
	UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]  initWithCustomView:rightButton];
	return rightBarButtonItem;
}

@end
